package com.it.taoyidian.controller;

import com.it.taoyidian.entity.ProductEntity;
import com.it.taoyidian.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
@Slf4j
public class ProductController {
    @Autowired
    @Qualifier("productService")
    private IProductService productService;
    @GetMapping("/home/findProductDetail/{productId}")
    public String findProductDetail(@PathVariable("productId") Integer productId, Model model){
        log.info("查看商品详情方法入参，productId:{}",productId);
        ProductEntity productEntity = productService.findProductDetail(productId);
        log.info("查询商品详情结果，productEntity:{}",productEntity);
        model.addAttribute("productEntity",productEntity);
        return "item_show";
    }

}
